function [priors, mmu, RR] = gmmparams(DIM, NUM_KERNELS, STDDEV_DOMAINSIZE_RATIO)
% generate GMM parameters and draw samples
% [priors,mmu,RR] = GMMPARAMS(DIM,NUM_KERNELS,[STDDEV_DOMAINSIZE_RATIO])
%
% DIM ... dimension
% NUM_KERNELS ... 
% DOMAIN_SIZE ... domain for mean values ([0...1] for all dimensions)
% 
% priors ... random priors for all kernels
% mmu ... random mean values for all kernels
% RR ... cholesky factorizations of random Sigmas for all kernels

    if nargin < 3, STDDEV_DOMAINSIZE_RATIO = 1/4; end
    
    rand('state',sum(100*clock));
    randn('state',sum(100*clock));
    
    %mmu = DOMAIN_SIZE*rand(NUM_KERNELS,DIM)-DOMAIN_SIZE/2;
    mmu = rand(NUM_KERNELS,DIM);
    
    RR = zeros(NUM_KERNELS,DIM^2);
    for i = 1:NUM_KERNELS  % triu input must be 2D
        fact = STDDEV_DOMAINSIZE_RATIO + randn*10^-1;
        tmp = fact*rand(DIM) - fact/2; 
        % could still emphasize main diag (of sigma!)?
        RR(i,:) = reshape(triu(tmp),1,DIM^2);
        %sigma = RR(i,:)'*RR(i,:)
    end
   
    priors = rand(NUM_KERNELS,1);
    priors = priors/sum(priors);

    %x_dummy = zeros(1,DIM);
    %gmmplot(x_dummy, mmu, RR);
    
end